<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"            
      xmlns:jb="http://java.sun.com/jsf/composite/componentes"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/pages/core/plantilla/plantillaPrincipal.xhtml">

        <ui:define name="contenido">          
            <h:form onsubmit="return checkSubmit();"  id="frmPrincipal">    
                <p:panel id="pnlPrincipal" header="#{i18n['ubigeo.titulo']}" style="#{applicationMBean.estiloTitulo}">
                    <h:panelGrid id="pgFormFilter" columns="10">
                        <p:commandButton icon="ui-icon ui-icon-search" title="#{i18n['general.button.buscar.filtro.tip']}" accesskey="#{applicationMBean.keyBuscar}"
                                         value="#{i18n['general.button.buscar.filtro']}" ajax="false" 
                                         style="#{applicationMBean.cssBotonBusqueda}"
                                         actionListener="#{ubigeoMBean.buscar}">
                            <p:ajax  update="idPngTree treeSingle" />
                        </p:commandButton>                          
                    </h:panelGrid>
                </p:panel>
                <p:contextMenu for="treeSingle">  
                    <p:menuitem value="#{i18n['general.button.nuevo']}" actionListener="#{ubigeoMBean.nuevaUbigeo}" icon="ui-icon-plusthick"  style="#{applicationMBean.estiloMenu}" 
                                oncomplete="dlgUbigeo.show()"
                                update=":idDlgUbigeo"/>  
                    <p:menuitem value="#{i18n['general.button.editar']}" oncomplete="dlgUbigeo.show()"
                                actionListener="#{ubigeoMBean.editarUbigeo}" update=":idDlgUbigeo"
                                icon="ui-icon-pencil" style="#{applicationMBean.estiloMenu}"/>   
                </p:contextMenu>  

                <h:panelGrid id="idPngTree">
                    <p:treeTable id="treeSingle" value="#{ubigeoMBean.ubigeos}" var="dto" 
                                 selectionMode="single"   styleClass="estiloPanel"
                                 selection="#{ubigeoMBean.selectedUbigeo}">                          
                        <p:column >  
                            <f:facet name="header">  
                                #{i18n['general.label.id']}  
                            </f:facet>  
                            <h:outputText value="#{dto.id}" />  
                        </p:column>  
                        <p:column>  
                            <f:facet name="header">  
                                #{i18n['ubigeo.descripcion']}  
                            </f:facet>  
                            <h:outputText value="#{dto.descripcion}" />  
                        </p:column>   
                        <p:column>  
                            <f:facet name="header">  
                                #{i18n['ubigeo.tipo']}  
                            </f:facet>  
                            <h:outputText value="#{dto.tipo}" />  
                        </p:column>   
                    </p:treeTable>
                </h:panelGrid>



            </h:form>
            <p:dialog id="idDlgUbigeo" rendered="true" modal="true"  header="#{i18n['ubigeo.panel']}" widgetVar="dlgUbigeo" style="#{applicationMBean.estiloTitulo}">                                   
                <jb:ubigeo />
            </p:dialog>
        </ui:define>
    </ui:composition>
</html>